<?php

namespace app\utils\data\ele;

use app\utils\ui\vue\VueVarValue;

/**
 * table v2 的列实例
 */
class TableV2Columns {
    private $columns=[];
    private $var;
    private $len;
    public function __construct($var,$columns=[])
    {
        $this->var=$var;
        $this->columns=$columns;
        $this->len=count($columns);
    }

    /**
     * 添加列
     */
    public function add_column(string $dataKey,string $title,int $width,...$prop){
        $key = $this->len;
        $temp = array(
            'key'=>$key,
            'dataKey'=>$dataKey,
            'title'=>$title,
            'width'=>$width
        ); 
        $this->columns[]=array_merge($prop,$temp);
        $this->len++;
        return $this;
    }



    /**
     * 用于输出变量
     */
    public function toColumns(){
        return new VueVarValue($this->var,$this->columns);
    }
    

}